//
//  WouldLikeView.m
//  quxiangtao
//
//  Created by HHuajiang on 2018/12/14.
//  Copyright © 2018 shanhaijin. All rights reserved.
//

#import "WouldLikeView.h"

@implementation WouldLikeView

- (instancetype)init {
    if (self == [super init]) {
        self.backgroundColor = [Color000000 colorWithAlphaComponent:0.6];
        UIImageView *image = [[UIImageView alloc] init];
        image.backgroundColor = [UIColor grayColor];
        image.userInteractionEnabled = YES;
        UITapGestureRecognizer * PrivateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageDidSelectd)];
        PrivateLetterTap.numberOfTouchesRequired = 1;
        PrivateLetterTap.numberOfTapsRequired = 1;
        [image addGestureRecognizer:PrivateLetterTap];
        [self addSubview:image];
        [image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(jisuan(560), jisuan(540)));
        }];
        self.image = image;
        
        UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [deleteButton setImage:[UIImage imageNamed:@"deleteH"] forState:UIControlStateNormal];
        [deleteButton setTintColor:WhiteColor];
        [self addSubview:deleteButton];
        [deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.mas_centerX);
            make.size.mas_equalTo(CGSizeMake(Scale_W(25), Scale_W(25)));
            make.top.equalTo(image.mas_bottom).offset(Margin);
        }];
        [deleteButton addTarget:self action:@selector(closuttonClick) forControlEvents:UIControlEventTouchUpInside];
               
    }
    return self;
}

- (void)imageDidSelectd {
    if (self.didSelectBlock) {
        self.didSelectBlock();
    }
    if (![CommonUserInfo sharedInstance].isLogin) {
        return;
    }
    [self closuttonClick];
}

- (void)closuttonClick {
    [self removeFromSuperview];
}

@end
